const db = require('./mysql')
module.exports = {
  // 注册
  register(user, password) {
    let id = ''
    let insert = "INSERT INTO `roots`.`use` VALUES (?,?,?,?,null)";
    let identity = ''
    db.query('select * from `use`', (err, results) => {
      id = results.length + 1
    })
    for (let i in user) {
      if (i > 6) {
        identity += user[i]
      }
    }
    setTimeout(() => {
      identity += id
      db.query(insert, [id, user, password, identity], (err, results) => {
        if (err) return console.log(err.message);
        if (results.affectedRows === 1) {
          console.log('插入成功');
        }
      })
    }, 500);


  }
}
